Microcontrollers provide a good balance between cost and performance for those applications which do not require extensive computing power, and which cannot bear expensive components. A microcontroller is typically a monolithic device, including a central processing unit (CPU), a read only memory (ROM), and a random access memory (RAM). The ROM contains instruction code for the CPU, and the RAM can hold current variable information required by the CPU as it completes the instructions read from the ROM.
Often, a microcontroller is able to access the internal ROM provided as a part of the microcontroller, and an external ROM. Typically, the external ROM can be of a larger capacity than the internal ROM. For example, the internal ROM may have a capacity of 32K bytes, and yet the microcontroller may be able to access an external ROM having a capacity of 64K bytes.
The microcontroller usually accesses either the internal or external ROM as the base memory, according to the level of the input on one of the microcontroller input pins. This input pin is typically referred to as the external access pin, or EA pin. For example, if the level of the signal on the EA is low, then the microcontroller may understand to access the external memory as the base memory, and if the level on the EA is high, then the microcontroller may understand to access the internal memory as the base memory.
If the internal memory is designated as the base memory, then all values at an address within the range of the internal memory are accessed by fetches from the internal memory. However, when an address above the range of the internal memory is requested, the value is accessed by a fetch from the external memory. Thus, with the internal memory designated as the base memory, all memory addresses of the internal memory are accessible, and the memory addresses of the external memory above the highest address of the internal memory are also accessible. Therefore, in this mode, the lower addresses of the external memory, which correspond to the addresses of the internal memory, are not accessible. If the external memory is designated as the base memory, then all values at an address within the range of the external memory are accessed by fetches from the external memory. In this mode the addresses of the internal memory are not accessible at all.
While it may appear to be a simple matter to access all of the memory available in the internal memory and external memory, placing this access within the control of the microcontroller is a difficult matter. One possible method for doing this is to connect an output of the microcontroller to the EA. Thus, the microcontroller could alter the level of the signal on the EA at any time that it desired to access the other memory as the base memory. Unfortunately, operating the microcontroller in this mode typically produces an unstable operation. Therefore, most microcontroller manufacturers recommend that the level on the EA remain stable after a reset, and will not guarantee the operation of the microcontroller under other circumstances.
The effect of this restriction is that an amount of memory space equal to the capacity of the internal memory is wasted when the external memory is the base memory, as the internal memory cannot be accessed in this mode. Alternatively, an amount of memory space equal to the capacity of the external memory below the highest address of the internal memory is wasted when the internal memory is the base memory, as this portion of the external memory cannot be accessed in this mode. Of course, it is possible to purchase microcontrollers which can access a larger memory address space if more memory is required. However, such microcontrollers cost more, and offset the cost-savings benefit of using an inexpensive microcontroller.
What is needed, therefore, is a method of inexpensively and reliably allowing a microcontroller to select and access all of the internal memory and external memory available to it.